package org.qiyu.live.account.provider;


import jakarta.annotation.Resource;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.qiyu.live.account.provider.service.IAccountTokenService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
 * @ClassName: AccountProviderApplication
 * @Description: TODO
 * @Author zhangguangyan
 * @Date 2023/08/29/ 20:47:10
 * @Version 1.0
 */
@SpringBootApplication
@EnableDubbo
@EnableDiscoveryClient
public class AccountProviderApplication implements CommandLineRunner {
    private static final Logger LOGGER = LoggerFactory.getLogger(AccountProviderApplication.class);
    @Resource
    private IAccountTokenService iAccountTokenService;
    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(AccountProviderApplication.class);
        springApplication.setWebApplicationType(WebApplicationType.NONE);
        springApplication.run(args);
    }


    @Override
    public void run(String... args) throws Exception {
       Long  userId = 138762L;
        String andSaveLoginToken = iAccountTokenService.createAndSaveLoginToken(userId);
        System.out.println("token is "+andSaveLoginToken);
        Long userIdByToken = iAccountTokenService.getUserIdByToken(andSaveLoginToken);
        System.out.println("matchUser is "+userIdByToken);
    }
}
